package com.myfoon.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name ="USER_FRIEND")
public class Friend {
    private Long id;
    private User owner;
    private User friend;
    
    public Friend() {
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Id
    @GeneratedValue(generator = "UserFriendSequence", strategy = GenerationType.AUTO)
    @SequenceGenerator(name = "UserFriendSequence", allocationSize = 1,
                       sequenceName = "USER_FRIEND_SEQ_01")
    @Column(name = "ID", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "OWNER")
    public User getOwner() {
        return owner;
    }

    public void setFriend(User friend) {
        this.friend = friend;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FRIEND_ID")
    public User getFriend() {
        return friend;
    }
}
